<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title>正则表达式之入门</title>
	<script type='text/javascript'>
	    function check1(){
	    	var a = /^1[34578]\d{9}$/ ;
	    	var b =a.test(document.getElementById('n1').value);
	    	if(b){ document.getElementById('p1').innerHTML='格式正确';}
	    		else{document.getElementById('p1').innerHTML='输入有误';}
	    }

	    function check2(){
	    	var a = /\b([a-zA-Z]+) \b\1/ ;
	    	var b =a.test(document.getElementById('n2').value);
	    	if(b){ document.getElementById('p2').innerHTML='格式正确';}
	    		else{document.getElementById('p2').innerHTML='输入有误';}
	    }
	</script>
</head>
<body>
    <div>
        <input id='n1' type="text" />
	    <button id='check1' onclick="check1()">检查是否为手机号码</button>
	    <p id='p1'></p>
    </div>
    <br/>
    <div>
        <input id='n2' type="text" />
	    <button id='check2' onclick="check2()">检查是否有相邻重复单词</button>
	    <p id='p2'></p>
    </div>
</body>
</html>